home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / gcc263-src.lha / gcc-2.6.3 / config / elxsi / elxsi.c next >
C/C++ Source or Header  |  1992-11-07  |  4KB  |  127 lines

  1. /* Subroutines for insn-output.c for GNU compiler.  Elxsi version.
  2.    Copyright (C) 1987, 1992 Free Software Foundation, Inc
  3.    This port, done by Mike Stump <mrs@cygnus.com> in 1988, and is the first
  4.    64 bit port of GNU CC.
  5.    Based upon the VAX port.
  6.  
  7. This file is part of GNU CC.
  8.  
  9. GNU CC is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 1, or (at your option)
  12. any later version.
  13.  
  14. GNU CC is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with GNU CC; see the file COPYING.  If not, write to
  21. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  22.  
  23. #include <stdio.h>
  24. #include "config.h"
  25. #include "rtl.h"
  26.  
  27. extern char *reg_names[];
  28. rtx cmp_op0=0, cmp_op1=0;
  29.  
  30. /* table of relations for compares and branches */
  31. char *cmp_tab[] = {
  32.     "gt", "gt", "eq", "eq", "ge", "ge", "lt", "lt", "ne", "ne",
  33.     "le", "le" };
  34.  
  35. /* type is the index into the above table */
  36. /* s is "" for signed, or "u" for unsigned */
  37. char *cmp_jmp(s, type, where) char *s; rtx where; {
  38.     rtx br_ops[3];
  39.     char template[50];
  40.     char *f = "";
  41.     char *bits = "64";
  42.     if (GET_MODE (cmp_op0) == SFmode) f = "f", bits = "32";
  43.     if (GET_MODE (cmp_op0) == DFmode) f = "f";
  44.     br_ops[0] = where;
  45.     br_ops[1] = cmp_op0;
  46.     br_ops[2] = cmp_op1;
  47.     if (cmp_op1)
  48.     sprintf(template, "%scmp%s.br.%s\t%%1,%%2:j%s\t%%l0",
  49.         f, s, bits, cmp_tab[type]);
  50.     else if (*f)
  51.     sprintf(template, "fcmp.br.%s\t%%1,=0:j%s\t%%l0",
  52.         bits, cmp_tab[type]);
  53.     else if (*s) /* can turn the below in to a jmp ... */
  54.     sprintf(template, "cmpu.br.64\t%%1,=0:j%s\t%%l0", s, cmp_tab[type]);
  55.     else
  56.     sprintf(template, "jmp.%s\t%%1,%%l0", cmp_tab[type+1]);
  57.     output_asm_insn(template, br_ops);
  58.     return "";
  59. }
  60.  
  61. char *cmp_set(s, type, reg) char *s, *type; rtx reg; {
  62.     rtx br_ops[3];
  63.     char template[50];
  64.     char *f = "";
  65.     char *bits = "64";
  66.     if (GET_MODE (cmp_op0) == SFmode) f = "f", bits = "32";
  67.     else if (GET_MODE (cmp_op0) == DFmode) f = "f";
  68.     else if (GET_MODE (cmp_op0) == SImode) bits = "32";
  69.     else if (GET_MODE (cmp_op0) == HImode) bits = "16";
  70.     else if (GET_MODE (cmp_op0) == QImode) bits = "8";
  71.     br_ops[0] = reg;
  72.     br_ops[1] = cmp_op0;
  73.     br_ops[2] = cmp_op1;
  74.     if (cmp_op1)
  75.     sprintf(template, "%scmp%s.%s\t%%0,%%1,%%2:%s",
  76.         f, s, bits, type);
  77.     else
  78.     sprintf(template, "%scmp%s.%s\t%%0,%%1,=0:%s",
  79.         f, s, bits, type);
  80.     output_asm_insn(template, br_ops);
  81.     return "";
  82. }
  83.  
  84. print_operand_address (file, addr)
  85.      FILE *file;
  86.      register rtx addr;
  87. {
  88.   register rtx reg1, reg2, breg, ireg;
  89.   rtx offset;
  90.  
  91.  retry:
  92.   switch (GET_CODE (addr))
  93.     {
  94.  
  95.     case MEM:
  96.       if (GET_CODE (XEXP (addr, 0)) == REG)
  97.         fprintf (file, "%s", reg_names[REGNO (addr)]);
  98.       else abort();
  99.       break;
  100.  
  101.     case REG:
  102.       fprintf (file, "[%s]", reg_names[REGNO (addr)]);
  103.       break;
  104.  
  105.     case PLUS:
  106.       reg1 = 0;    reg2 = 0;
  107.       ireg = 0;    breg = 0;
  108.       offset = 0;
  109.       if (GET_CODE (XEXP (addr, 0)) == REG)
  110.     {
  111.       offset = XEXP (addr, 1);
  112.       addr = XEXP (addr, 0);
  113.     }
  114.       else if (GET_CODE (XEXP (addr, 1)) == REG)
  115.     {
  116.       offset = XEXP (addr, 0);
  117.       addr = XEXP (addr, 1);
  118.     }
  119.       fprintf (file, "[%s]", reg_names[REGNO (addr)]);
  120.       output_address (offset);
  121.       break;
  122.  
  123.     default:
  124.       output_addr_const (file, addr);
  125.     }
  126. }
  127.